/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pm.gui.components;

import pm.devices.drives.Drive;

import javax.swing.*;
import java.awt.*;

/**
 * @author Администратор
 */
public class DeviceLabel extends JLabel
		implements ListCellRenderer {

	public Component getListCellRendererComponent(
			JList list,
			Object value,
			int index,
			boolean isSelected,
			boolean cellHasFocus) {

		final Drive drive = (Drive) value;

		if (drive == null) {
			return new JLabel("");
		}
		if (isSelected) {
			setBackground(list.getSelectionBackground());
			setForeground(list.getSelectionForeground());
		} else {
			setBackground(list.getBackground());
			setForeground(list.getForeground());
		}

		setIcon(drive.getIcon());
		setText(drive.getDisplayableText());
		setFont(list.getFont());

		return this;
	}
}
